package com.qdlc.p2p.dal.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.common.model.jpa.PageDataList;
import com.qdlc.p2p.dal.common.model.jpa.QueryParam;
import com.qdlc.p2p.dal.common.model.jpa.SearchFilter;
import com.qdlc.p2p.dal.dto.AdditionalCommodity;
import com.qdlc.p2p.dal.dto.CashAwardRule;
import com.qdlc.p2p.dal.model.AdditionalCommodityModel;
import com.qdlc.p2p.dal.model.ReceivingInfoModel;
import com.qdlc.p2p.dal.mybatis.model.mapper.CashAwardRuleMapper;
import com.qdlc.p2p.dal.mybatis.pager.PageProxyBuilder;
import com.qdlc.p2p.dal.mybatis.pager.core.PageParameter;
import org.springframework.stereotype.Repository;

import com.qdlc.p2p.dal.common.dao.jpa.BaseDaoImpl;
import com.qdlc.p2p.dal.dao.ReceivingInfoDao;
import com.qdlc.p2p.dal.dto.ReceivingInfo;
import com.qdlc.p2p.dal.mybatis.model.mapper.ReceivingInfoMapper;

@Repository("receivingInfoDao")
public class ReceivingInfoDaoImpl extends BaseDaoImpl<ReceivingInfo> implements ReceivingInfoDao {

	@Resource
	ReceivingInfoMapper receivingInfoMapper;
	
	
	@Override
	public ReceivingInfo findById(long id) {
		ReceivingInfo info = receivingInfoMapper.findById(id);
		return info;
	}

	@Override
	public void setUnDefult(long userId) {
		receivingInfoMapper.setUnDefultByUserId(userId);
	}
	
	@Override
	public void setDefult(long id, long userId) {
		receivingInfoMapper.setDefultByUserId(id, userId);
	}

	@Override
	public void disable(long id, long userId) {
		receivingInfoMapper.disable(id, userId);
	}

	@Override
	public List<ReceivingInfo> list(long userId, int status) {
		List<ReceivingInfo> list = receivingInfoMapper.list(userId, status);
		return list;
	}

	@Override
	public int count(long userId, int status) {
		int count = receivingInfoMapper.count(userId, status);
		return count;
	}

	@Override
	public PageDataList<ReceivingInfoModel> list(ReceivingInfoModel model) {
		PageProxyBuilder<ReceivingInfoMapper> proxy = PageProxyBuilder.newBuilder(ReceivingInfoMapper.class);
		proxy.setPageParameter(model.getPage(), model.getRows());
		List<ReceivingInfoModel> modelList;
		modelList = proxy.createProxy().findByModel(model);
		PageParameter pageParameter = proxy.getPageParameter();
		PageDataList<ReceivingInfoModel> dataList = new PageDataList<ReceivingInfoModel>(pageParameter.convert2Page(), modelList);
		return dataList;
	}
}